﻿<Page 
    x:Class="PerspectiveDemo.Wpf.View.MayaEaseDemo"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:p="http://www.codeplex.com/perspective"
    Style="{StaticResource PageStyle}"
	Title="MayaEaseDemo">
    <Page.Resources>
        <Style 
            x:Key="LineStyle"
            TargetType="Line">
            <Setter Property="Stroke" Value="LightGray" />
            <Setter Property="StrokeThickness" Value="1" />
            <Setter Property="StrokeEndLineCap" Value="Triangle" />
        </Style>
        <Style 
            x:Key="ArrowCapStyle" 
            TargetType="Polygon">
            <Setter Property="Stroke" Value="LightGray" />
            <Setter Property="StrokeThickness" Value="1" />
            <Setter Property="Fill" Value="LightGray" />
        </Style>
        <Style 
            x:Key="UpArrowCapStyle" 
            TargetType="Polygon"
            BasedOn="{StaticResource ArrowCapStyle}">
            <Setter Property="Shape.RenderTransform">
                <Setter.Value>
                    <TransformGroup>
                        <RotateTransform CenterX="1.5" CenterY="1.5" Angle="135" />
                        <TranslateTransform X="-1.5" Y="-1.5" />
                    </TransformGroup>
                </Setter.Value>
            </Setter>
        </Style>
        <Style 
            x:Key="RightArrowCapStyle" 
            TargetType="Polygon"
            BasedOn="{StaticResource ArrowCapStyle}">
            <Setter Property="RenderTransform">
                <Setter.Value>
                    <TransformGroup>
                        <RotateTransform CenterX="1.5" CenterY="1.5" Angle="225" />
                        <TranslateTransform X="-1.5" Y="-1.5" />
                        <!--<ScaleTransform ScaleX="2" ScaleY="2" />-->
                    </TransformGroup>
                </Setter.Value>
            </Setter>
        </Style>
        <Transform3DGroup 
            x:Shared="false"
            x:Key="SquareTransform">
            <RotateTransform3D 
                CenterX="0.5"
                CenterY="0.5"
                CenterZ="-0.5">
                <RotateTransform3D.Rotation>
                    <AxisAngleRotation3D
                        Axis="1,0,0" />
                </RotateTransform3D.Rotation>
            </RotateTransform3D>
            <ScaleTransform3D ScaleX="3" ScaleY="2" ScaleZ="2"/>
            <TranslateTransform3D OffsetZ="3" />
        </Transform3DGroup>
        <!--Storyboard.TargetProperty="(p:Square3D.Transform).(RotateTransform3D.Rotation).(AxisAngleRotation3D.Angle)"-->
        <DoubleAnimation
                x:Key="Animation1"
                Storyboard.TargetName="square1" 
                Storyboard.TargetProperty="(p:Square3D.Transform).Children[0].(RotateTransform3D.Rotation).(AxisAngleRotation3D.Angle)" 
                Duration="0:0:20"
                From="0" To="360"/>
        <DoubleAnimation
                x:Key="Animation2"
                Storyboard.TargetName="square2" 
                Storyboard.TargetProperty="(p:Square3D.Transform).Children[0].(RotateTransform3D.Rotation).(AxisAngleRotation3D.Angle)" 
                Duration="0:0:20"
                From="90" To="450"/>
        <DoubleAnimation
                x:Key="Animation3"
                Storyboard.TargetName="square3" 
                Storyboard.TargetProperty="(p:Square3D.Transform).Children[0].(RotateTransform3D.Rotation).(AxisAngleRotation3D.Angle)" 
                Duration="0:0:20"
                From="180" To="540"/>
        <DoubleAnimation
                x:Key="Animation4"
                Storyboard.TargetName="square4" 
                Storyboard.TargetProperty="(p:Square3D.Transform).Children[0].(RotateTransform3D.Rotation).(AxisAngleRotation3D.Angle)" 
                Duration="0:0:20"
                From="270" To="630"/>
        <Storyboard 
            x:Key="Storyboard1"
            RepeatBehavior="Forever"
            >
            <Storyboard.Children>
                <TimelineCollection>
                    <StaticResource ResourceKey="Animation1"/>
                    <StaticResource ResourceKey="Animation2"/>
                    <StaticResource ResourceKey="Animation3"/>
                    <StaticResource ResourceKey="Animation4"/>
                </TimelineCollection>
            </Storyboard.Children>
        </Storyboard>
    </Page.Resources>
    <StackPanel  Margin="10">
        <StackPanel Orientation="Horizontal">
            <Button 
                Name="bMaya" 
                Margin="2"
                Content="Maya In" 
                Click="bMaya_Click" />
            <Button 
                Name="bMaya2" 
                Margin="2"
                Content="Maya In 0.5" 
                Click="bMaya2_Click" />
            <Button 
                Name="bMaya3" 
                Margin="2"
                Content="Maya Out" 
                Click="bMaya3_Click" />
            <Button 
                Name="bMaya4" 
                Margin="2"
                Content="Maya InOut" 
                Click="bMaya4_Click" />
        </StackPanel>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Viewbox Grid.Column="0">
                <Grid
                        Height="185"
                        Width="185">
                    <Canvas 
                            Name="canvas"
                            Width="120"
                            Height="120"
                            VerticalAlignment="Bottom"
                            Loaded="Canvas_Loaded"
                            >
                        <Ellipse 
                                Fill="LightGray"
                                Canvas.Left="-1"
                                Canvas.Top="99"
                                Width="2"
                                Height="2"/>
                        <Line 
                                Style="{StaticResource LineStyle}"
                                X1="0" Y1="100" X2="100" Y2="100" />
                        <Polygon
                                Style="{StaticResource RightArrowCapStyle}"
                                Canvas.Top="100"
                                Canvas.Left="100"
                                Points="
                                    0, 0 
                                    0, 3 
                                    3, 3"/>
                        <TextBlock 
                                Canvas.Top="102" Canvas.Left="75" 
                                FontSize="6"
                                Text="Time"/>
                        <Line 
                                Style="{StaticResource LineStyle}"
                                X1="0" Y1="100" X2="0" Y2="0" />
                        <Polygon
                                Style="{StaticResource UpArrowCapStyle}"
                                Canvas.Top="0"
                                Points="
                                0, 0 
                                0, 3 
                                3, 3"/>
                        <TextBlock 
                                Canvas.Top="5" Canvas.Left="-10" 
                                FontSize="6"
                                Text="Value">
                            <TextBlock.RenderTransform>
                                <TransformGroup>
                                    <RotateTransform Angle="-90"/>
                                    <TranslateTransform Y="40" />
                                </TransformGroup>
                            </TextBlock.RenderTransform>
                        </TextBlock>
                    </Canvas>
                </Grid>
            </Viewbox>
            <p:Workshop3D Grid.Column="1">
                <!--<p:XyzAxis3D Length="3.0"/>-->
                <p:Square3D 
                    x:Name="square1"
                    Transform="{StaticResource SquareTransform}">
                    <p:Square3D.Material>
                        <DiffuseMaterial>
                            <DiffuseMaterial.Brush>
                                <ImageBrush 
                                    ImageSource="http://www.odewit.net/Images/Demo/LA01-s400.jpg" 
                                    TileMode="None" 
                                    Stretch="Fill"/>
                            </DiffuseMaterial.Brush>
                        </DiffuseMaterial>
                    </p:Square3D.Material>
                    <!--<p:Square3D.Transform>
                        <RotateTransform3D>
                            <RotateTransform3D.Rotation>
                                <AxisAngleRotation3D 
                                    Axis="1,0,0" />
                            </RotateTransform3D.Rotation>
                        </RotateTransform3D>
                    </p:Square3D.Transform>-->
                </p:Square3D>
                <p:Square3D 
                    x:Name="square2"
                    Transform="{StaticResource SquareTransform}">
                    <p:Square3D.Material>
                        <DiffuseMaterial>
                            <DiffuseMaterial.Brush>
                                <ImageBrush 
                                    ImageSource="http://www.odewit.net/Images/Demo/Vegas03-s400.jpg" 
                                    TileMode="None" 
                                    Stretch="Fill"/>
                            </DiffuseMaterial.Brush>
                        </DiffuseMaterial>
                    </p:Square3D.Material>
                </p:Square3D>
                <p:Square3D 
                    x:Name="square3"
                    Transform="{StaticResource SquareTransform}">
                    <p:Square3D.Material>
                        <DiffuseMaterial>
                            <DiffuseMaterial.Brush>
                                <ImageBrush 
                                    ImageSource="http://www.odewit.net/Images/Demo/Colorado01-s400.jpg" 
                                    TileMode="None" 
                                    Stretch="Fill"/>
                            </DiffuseMaterial.Brush>
                        </DiffuseMaterial>
                    </p:Square3D.Material>
                </p:Square3D>
                <p:Square3D 
                    x:Name="square4"
                    Transform="{StaticResource SquareTransform}">
                    <p:Square3D.Material>
                        <DiffuseMaterial>
                            <DiffuseMaterial.Brush>
                                <ImageBrush 
                                    ImageSource="http://www.odewit.net/Images/Demo/Colorado02-s400.jpg" 
                                    TileMode="None" 
                                    Stretch="Fill"/>
                            </DiffuseMaterial.Brush>
                        </DiffuseMaterial>
                    </p:Square3D.Material>
                </p:Square3D>
            </p:Workshop3D>
        </Grid>
    </StackPanel>
</Page>
